package com.lynx.system.controller;

import com.lynx.system.beans.User;
import com.lynx.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.nio.file.Path;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/findAll/{index}/{limit}")
    public Object findAll(@PathVariable int index,@PathVariable int limit){
        return userService.findAll(index,limit);
    }
    @GetMapping("/findCount")
    public Object findCount(){
        return userService.findCount();
    }
    @GetMapping("/findById/{id}")
    public Object findById(@PathVariable long id){
        return  userService.findById(id);
    }
    @PostMapping("/addUser")
    public Object addUser(@RequestBody User user){
        return userService.addUser(user);
    }
    @PostMapping("/editUser")
    public Object editUser(@RequestBody User user){
        return userService.editUser(user);
    }
    @DeleteMapping("/removeUser/{id}")
    public Object removeUser(@PathVariable int id){
        return userService.removeUser(id);
    }

}
